import request from '/@/utils/request';

/**
 * 获取租户列表
 * @link 参考：https://api.lmabbe.com/doc.html#/platform/%E7%A7%9F%E6%88%B7%E7%AE%A1%E7%90%86/listUsingGET_2
 * @param params 要传的参数值，非必传
 * @returns 返回接口数据
 */
export function getTenantList(params?: object) {
	return request({
		url: '/plat/tenant/page',
		method: 'get',
		params,
	});
}

/**
 * 获取租户详情
 * @link 参考：https://api.lmabbe.com/doc.html#/platform/%E7%A7%9F%E6%88%B7%E7%AE%A1%E7%90%86/getByIdUsingGET
 * @param params 要传的参数值，非必传
 * @returns 返回接口数据
 */
export function getTenantInfo(id?: any) {
	return request({
		url: `/plat/tenant/${id}`,
		method: 'get',
	});
}

/**
 * 新增租户信息
 * @link 参考：https://api.lmabbe.com/doc.html#/platform/%E7%A7%9F%E6%88%B7%E7%AE%A1%E7%90%86/addUsingPOST
 * @param params 要传的参数值，非必传
 * @returns 返回接口数据
 */
export function addTenantInfo(params?: object) {
	return request({
		url: '/plat/tenant',
		method: 'post',
		data: params,
	});
}

/**
 * 修改租户信息
 * @link 参考：https://api.lmabbe.com/doc.html#/platform/%E7%A7%9F%E6%88%B7%E7%AE%A1%E7%90%86/updateUsingPUT
 * @param params 要传的参数值，非必传
 * @returns 返回接口数据
 */
export function modTenantInfo(params?: object, id?: any) {
	return request({
		url: `/plat/tenant`,
		method: 'put',
		data: params,
	});
}

export function delTenantInfo(tenantId: any) {
	return request({
		url: `/plat/tenant/${tenantId}`,
		method: 'DELETE',
	});
}

export function getAllMiniApps(tenantId: any) {
	return request({
		url: `/plat/tenant/${tenantId}/miniapps`,
		method: 'get',
	});
}

export function getAllDatabases(tenantId: any) {
	return request({
		url: `/plat/tenant/${tenantId}/databases`,
		method: 'get',
	});
}

export function getAllOauthClient(tenantId: any) {
	return request({
		url: `/plat/tenant/${tenantId}/oauthClient`,
		method: 'get',
	});
}

export function renewal(tenantId: any, overdueTime: string) {
	return request({
		url: `/plat/tenant/${tenantId}/renewal`,
		method: 'post',
		data: { overdueTime: overdueTime },
	});
}
